package com.designoutput.ui.gallery
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;

	public class GalleryNavigationItem extends Sprite
	{
		private var roundBg:Sprite;
		private var labelText:TextField;
		private var _index:int;
		private var isMarked:Boolean = false;
		public function GalleryNavigationItem()
		{
			this.graphics.beginFill(0x042b2d, 1);//0x5C5449
			this.graphics.drawRect(0, 0, 200, 32);
			this.graphics.endFill();

			roundBg=new Sprite;
			roundBg.graphics.beginFill(0xD3D6D3, 0.5);
			roundBg.graphics.drawRoundRect(5, 5, 190, 22, 10);
			roundBg.graphics.endFill();
			addChild(roundBg);
			roundBg.visible=false;

			this.labelText=new TextField();
			this.labelText.width = 180;
			this.labelText.y=6;
			this.labelText.x=10;
			this.labelText.defaultTextFormat=new TextFormat("Arial, Helvetica, San-serif", 12,0xFFFFFF, false, false, false, null, null, "center");
			this.labelText.height=18;
			this.labelText.multiline=false;
			this.labelText.selectable=false;
			addChild(this.labelText);

			this.addEventListener(MouseEvent.MOUSE_OVER, overHandler);
			this.addEventListener(MouseEvent.MOUSE_OUT, outHandler);
		}


		public function get index():int
		{
			return _index;
		}

		public function set index(value:int):void
		{
			_index = value;
		}

		private function overHandler(evt:MouseEvent):void
		{
			if(this.isMarked){
				return;
			}
			this.roundBg.visible=true;
		}

		private function outHandler(evt:MouseEvent):void
		{
			if(this.isMarked){
				return;
			}
			this.roundBg.visible=false;
		}

		public function set label(val:String):void
		{
			this.labelText.text=val;
		}
		
		public function Mark(flag:Boolean):void{
			this.isMarked = flag;
			if(flag){
				this.roundBg.visible=true;
			}else{
				this.roundBg.visible=false;
			}
		}
		
		
	}
}